package com.xxl.job.common.config;

import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * application文件后缀环境获取类
 *
 * @author : zyc
 * @version : 1.0
 * @create : 2024/08/16 15:14
 **/
@Component
public class ProfileManager {
    private final Environment environment;

    private static String active;

    private final static String ACTIVE = "spring.profiles.active";

    /**
     * 初始化
     */
    @PostConstruct
    public void init() {
        active = environment.getProperty(ACTIVE);
    }

    public ProfileManager(Environment environment) {
        this.environment = environment;
    }

    /**
     * 获取 application 文件环境值
     */
    public static String getActiveProfile() {
        return active;
    }
}
